﻿Vue.component('datepicker', {
    template: '<input type="text" class="form-control" />',
    props: ['value'],
    mounted: function () {
        var vm = this;

        $(this.$el).datetimepicker({
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            minView: "month",
            initialDate: new Date(),
            autoclose: true
        })
        .val(this.value)
        .trigger('change')
        .on('change',
        function () {
            vm.$emit('input', this.value)
        });
    },
    watch: {
        value: function (value) {
            $(this.$el).val(value).trigger('change');
        }
    },
    destroyed: function () {
        $(this.$el).off().datepicker('destroy')
    }
})